Jump to content

(vl-load-com) why not recognise vla-get-linetype?


Johntosh

Recommended Posts

I'm currently getting errors...

 

ActiveX Server returned the error: unknown name: Path

ActiveX Server returned the error: unknown name: Linetype

ActiveX Server returned the error: unknown name: IsXref

 

...even though I have (vl-load-com) at the top of the function.

 

Any assistance appreciated.

Link to comment
Share on other sites

Your object hasn't this properties. Use vlax-property-available-p function to check it. For example get ActiveDocument object and check path property:

 

Command: (setq actDoc(vla-get-ActiveDocument(vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 01ffa950>
Command: (vlax-property-available-p actDoc 'Path)
T
Command: (vla-get-Path actDoc)
"C:\\Documents and Settings\\Administrator\\My Documents"

 

It exists. Now check Linetype property:

 

Command: (vla-get-Linetype actDoc 'Linetype)
; error: ActiveX Server returned the error: unknown name: Linetype

 

This property missed in ActiveDocument object. To look list of all properties and methods for each object use vlax-dump-object function and the ActiveX and VBA Reference inside Developer Help:

 

Command: (vlax-dump-object actDoc t)
; IAcadDocument: An AutoCAD drawing
; Property values:
;   Active (RO) = -1
;   ActiveDimStyle = #<VLA-OBJECT IAcadDimStyle 0e7f4fac>
;   ActiveLayer = #<VLA-OBJECT IAcadLayer 0e826a6c>
;   ActiveLayout = #<VLA-OBJECT IAcadLayout 0e826a1c>
;   ActiveLinetype = #<VLA-OBJECT IAcadLineType 0e826abc>
;   ActiveMaterial = #<VLA-OBJECT IAcadMaterial 0e8266fc>
;   ActivePViewport = AutoCAD: No active viewport in paperspace
;   ActiveSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 0e7d925c>
;   ActiveSpace = 1
;   ActiveTextStyle = #<VLA-OBJECT IAcadTextStyle 0e826b0c>
;   ActiveUCS = AutoCAD: Null object ID
;   ActiveViewport = #<VLA-OBJECT IAcadViewport 0e826b5c>
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
;   Blocks (RO) = #<VLA-OBJECT IAcadBlocks 0e826bac>
;   Database (RO) = #<VLA-OBJECT IAcadDatabase 0e7d850c>
;   Dictionaries (RO) = #<VLA-OBJECT IAcadDictionaries 0e826bfc>
;   DimStyles (RO) = #<VLA-OBJECT IAcadDimStyles 0e826c4c>
;   ElevationModelSpace = 0.0
;   ElevationPaperSpace = 0.0
;   FileDependencies (RO) = #<VLA-OBJECT IAcadFileDependencies 0e8309ec>
;   FullName (RO) = ""
;   Groups (RO) = #<VLA-OBJECT IAcadGroups 0e826c9c>
;   Height = 702
;   HWND (RO) = 396484
;   Layers (RO) = #<VLA-OBJECT IAcadLayers 0e826cec>
;   Layouts (RO) = #<VLA-OBJECT IAcadLayouts 0e826d3c>
;   Limits = (0.0 0.0 420.0 297.0)
;   Linetypes (RO) = #<VLA-OBJECT IAcadLineTypes 0e826d8c>
;   Materials (RO) = #<VLA-OBJECT IAcadMaterials 0e826ddc>
;   ModelSpace (RO) = #<VLA-OBJECT IAcadModelSpace2 0e826e2c>
;   MSpace = AutoCAD: Invalid mode
;   Name (RO) = "Drawing1.dwg"
;   ObjectSnapMode = 0
;   PaperSpace (RO) = #<VLA-OBJECT IAcadPaperSpace2 0e826e7c>
;   Path (RO) = "C:\\Documents and Settings\\Administrator\\My Documents"
;   PickfirstSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 0e7d95ec>
;   Plot (RO) = #<VLA-OBJECT IAcadPlot 0e830e2c>
;   PlotConfigurations (RO) = #<VLA-OBJECT IAcadPlotConfigurations 0e826ecc>
;   Preferences (RO) = #<VLA-OBJECT IAcadDatabasePreferences 0e8309c4>
;   ReadOnly (RO) = 0
;   RegisteredApplications (RO) = #<VLA-OBJECT IAcadRegisteredApplications 
0e826f1c>
;   Saved (RO) = 0
;   SectionManager (RO) = Exception occurred
;   SelectionSets (RO) = #<VLA-OBJECT IAcadSelectionSets 0e7fb50c>
;   SummaryInfo (RO) = #<VLA-OBJECT IAcadSummaryInfo 0e830a8c>
;   TextStyles (RO) = #<VLA-OBJECT IAcadTextStyles 0e826f6c>
;   UserCoordinateSystems (RO) = #<VLA-OBJECT IAcadUCSs 0e826fbc>
;   Utility (RO) = #<VLA-OBJECT IAcadUtility 0e8349a4>
;   Viewports (RO) = #<VLA-OBJECT IAcadViewports 0e82700c>
;   Views (RO) = #<VLA-OBJECT IAcadViews 0e82705c>
;   Width = 1066
;   WindowState = 3
;   WindowTitle (RO) = "Drawing1.dwg"
; Methods supported:
;   Activate ()
;   AuditInfo (1)
;   Close (2)
;   CopyObjects (3)
;   EndUndoMark ()
;   Export (3)
;   GetVariable (1)
;   HandleToObject (1)
;   Import (3)
;   LoadShapeFile (1)
;   New (1)
;   ObjectIdToObject (1)
;   Open (2)
;   PurgeAll ()
;   Regen (1)
;   Save ()
;   SaveAs (3)
;   SendCommand (1)
;   SetVariable (2)
;   StartUndoMark ()
;   Wblock (2)
T

Link to comment
Share on other sites

Thanks for your help, ASIM.

 

One thing I don't get is if I have already a linetype collection then why isn't an item of the collection recognised as a linetype?

 

(defun c:test ()

(vl-load-com)

(vlax-for item (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))

(if (= (vla-get-linetype item) :vlax-true)

(princ item)

)

(princ)

)

Link to comment
Share on other sites

why isn't an item of the collection recognised as a linetype?

 

Because Linetype (Item of Linetypes) is also object which have the Name property:

 

(defun c:test ()
(vl-load-com)
(vlax-for item (vla-get-linetypes
	 (vla-get-activedocument
	   (vlax-get-acad-object)))
(princ(strcat "\n"(vla-get-Name item)))
)
(textscr)
(princ)
)

Link to comment
Share on other sites

Thank you, ASIM. I really appreciate your tutelage.

 

I've been at this juncture before between entities and names of entites and propertoes thereof!

 

Thanks again, enjoy the weekend.

 

God bless you.

Link to comment
Share on other sites

  • 12 years later...

Help to correct below route !

I wanted to have all line types as text file

 

(defun c:testline ( / item fileName fn exlintyp )
(vl-load-com)
(setq fileName "D:\\MyLineTypeTextFile.txt")
(vlax-for item (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))
(princ (strcat "\n"(vla-get-Name item ))))
(princ (strcat "\nTotal of " (itoa (sslength item )) " Line Type(s) ... " ))
(progn
(setq fn (open fileName "w"))
(setq exlintyp (vla-get-Name item))
(textscr)
(write-line exlintyp fn)
(close fn))
(princ))

 

  • Like 1
Link to comment
Share on other sites

My take

 

(defun c:testline ( / item fileName fn exlintyp )
(vl-load-com)
(setq fileName "D:\\MyLineTypeTextFile.txt")
(setq lines (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))))

(princ (strcat "\nTotal of " (itoa (vla-get-count lines)) " Line Type(s) ... " ))

(setq fn (open fileName "w"))
(vlax-for LT lines
  (princ (strcat "\n"(vla-get-Name LT )))
  (setq exlintyp (vla-get-Name LT))
  (write-line exlintyp fn)
)

(close fn)

(princ)
)
(c:testline)

 

Another similar task just did this for a particular problem.

 

; draw all linetypes as a look at
; By AlanH Oct 2021

(setq pt (getpoint "\nPick a point for linetypes"))

(setq lts  (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))))
(setq lst '())
(vlax-for ltname lts
  (setq ltn (vla-get-name ltname))
  (princ (strcat "\n" ltn))
  (if (or (= ltn "ByBlock")(= ltn "ByLayer"))
    (princ "ByBlock or Bylayer")
    (setq lst (cons ltn lst))
  )
)
(setq lst (vl-sort lst '<))

(foreach lt lst
  (setq pt2 (mapcar '+ pt (list 60.0 0.0 0.0)))
  (command "Line" pt pt2 "")
  (vla-put-linetype (vlax-ename->vla-object  (entlast)) lt)
  (setq pt2 (mapcar '+ pt (list 75.0 0.0 0.0)))
  (command "text" pt2 3.5 0.0 lt)
  (setq pt (mapcar '+ pt (list 0.0 -10.0 0.0)))
)

 

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...