Hi,
From a drawing, I need read custom properties of a part, none custom properties of the draw. And without open the part. I know how to read it in the part but no from the draw.
thanks,
Jacques
SolidworksApi macros
Hi,
From a drawing, I need read custom properties of a part, none custom properties of the draw. And without open the part. I know how to read it in the part but no from the draw.
thanks,
Jacques
SolidworksApi macros
You can use the codes to read the properties of part by referring to a view of that part in the drawing. There are some similar macro in this forum (sorry can't find them right now). Try for a search.
Like Deepak said, If the drawing is open, access the part by finding the default view, and getting the associated part.
If you don't want to open anything in SW, use the Document Manager object. This requires a (free) license code from SW. Document Manager will give you access to a file's references and properties without opening in SW.
Hi,
I complete my question. In fact, I know how access a part's custom propertie from a draw
i.e. :
Set myNote = Part.InsertNote("$PRPMODEL:""Description""")
and the note print : "TUBING HSS 44W ; 2" x 2" x 3/16" x 93 1/2" LG"
But, I want to access the code of my custom properties "Description":
i.e. :
TUBING HSS 44W ; "HAUT@Esquisse1@HSS-7013.SLDPRT" x "LARG@Esquisse1@HSS-7013.SLDPRT" x "EPAIS@Esquisse1@HSS-7013.SLDPRT" x "LONG@Extrusion1@HSS-7013.SLDPRT" LG
Thanks,
Jacques
sample code to access the custom property from a drawing:
Set swView = swModel.SelectionManager.GetSelectedObjectsDrawingView2(1, -1) ' selects view of first pick
Children = swView.GetVisibleComponents
Set swChild = Children(0) ' first componet in children
swName = swChild.Name2 ' instance and name of componet
Set swModel = swChild.GetModelDoc2
Set swConfig = swModel.GetActiveConfiguration ' this gets the default configuration of the part model
swConfigName = swConfig.Name
det = swModel.CustomInfo2(swConfigName, "DetailNo") ' configuration specific detail number field
etc......
(or something to that effect)
If I understand your question correctly, you can use the ICommandManager::Get3 method to get both values, the "code" value and the "text" value.
this is an API for SW2012. And I have 2010, so I keep this code for the future.
Thanks
Check the macro in this post. It pulls part custom property to be used in file name and can be modified to needs.
Re: Save as DWG with filename based on Costum properties?